<!--//
////////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 2009 -2010 addgadget.com  All rights reserved.
//
//  http://addgadget.com/
//
////////////////////////////////////////////////////////////////////////////////
//-->

var NetLib;var interfaceCount=0;var Int_Nr = "";function onLoad(){debugLog("### LOAD SETTINGS ###");debugLog("GetLibrary (Settings)");NetLib = GetLibrary();initSettings();var wbemFlagReturnImmediately = 0x10;var wbemFlagForwardOnly = 0x20;var objWMIService = GetObject("winmgmts:\\\\" + "localhost" + "\\root\\CIMV2");var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPenabled=True", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly);var enumItems = new Enumerator(colItems);if(enumItems.atEnd()){newOption = new Option("no connected Device", i);interface.options[interface.length] = newOption;}for (var i=0; !enumItems.atEnd(); enumItems.moveNext()){var objItem = enumItems.item();var name=objItem.Description;if(name.length > 42) name = name.substr(0,42);newOption = new Option(name, i);interface.options[interface.length] = newOption; i++;}Int_Nr = System.Gadget.Settings.read("Int_Nr");if (Int_Nr == "") interface.selectedIndex = 0; else interface.selectedIndex = Int_Nr;System.Gadget.onSettingsClosing = SettingsClosing;showUpdate();}function onUnload(){debugLog("### UNLOAD SETTINGS ###");}function SettingsClosing(event){debugLog("SettingsClosing:" + event);if (event.closeAction == event.Action.commit) saveSettings();{Int_Nr = interface.value;System.Gadget.Settings.write ("Int_nr", Int_Nr);}event.cancel = false;}function initSettings(){debugLog("initSettings");interfaceCount = NetLib.Initialize();fillInterfaceCombo();loadSettings();}function loadSettings(){debugLog("loadSettings");debugLog("loadSettings:Interface->"+ System.Gadget.Settings.read("interface"));Interface.value = System.Gadget.Settings.read("interface");debugLog("loadSettings:DrawStyle->"+ System.Gadget.Settings.read("drawstyle"));DrawStyle.value = System.Gadget.Settings.read("drawstyle");debugLog("loadSettings:ScaleType->"+ System.Gadget.Settings.read("scaletype"));ScaleType.value = System.Gadget.Settings.read("scaletype");debugLog("loadSettings:ScaleSize->"+ System.Gadget.Settings.read("scalesize"));ScaleSize.value = System.Gadget.Settings.read("scalesize");debugLog("loadSettings:background->"+ System.Gadget.Settings.read("background"));background.value = System.Gadget.Settings.read("background");debugLog("loadSettings:vismode->"+ System.Gadget.Settings.read("vismode"));VisMode.value = System.Gadget.Settings.read("vismode");debugLog("loadSettings:barup->"+ System.Gadget.Settings.read("barup"));barup.value = System.Gadget.Settings.read("barup");debugLog("loadSettings:bardown->"+ System.Gadget.Settings.read("bardown"));bardown.value = System.Gadget.Settings.read("bardown");size.value = System.Gadget.Settings.read("size");flyout.value = System.Gadget.Settings.read("flyout");}function saveSettings(){debugLog("saveSettings");debugLog("saveSettings:interface->"+ Interface.value);System.Gadget.Settings.write("interface", Interface.value);debugLog("saveSettings:drawstyle->"+ DrawStyle.value);System.Gadget.Settings.write("drawstyle", DrawStyle.value);debugLog("saveSettings:scaletype->"+ ScaleType.value);System.Gadget.Settings.write("scaletype", ScaleType.value);debugLog("saveSettings:scalesize->"+ ScaleSize.value);System.Gadget.Settings.write("scalesize", ScaleSize.value);debugLog("saveSettings:background->"+ background.value);System.Gadget.Settings.write("background", background.value);debugLog("saveSettings:vismode->"+ VisMode.value);System.Gadget.Settings.write("vismode", VisMode.value);debugLog("saveSettings:barup->"+ barup.value);System.Gadget.Settings.write("barup", barup.value);debugLog("saveSettings:bardown->"+ bardown.value);System.Gadget.Settings.write("bardown", bardown.value);System.Gadget.Settings.write("size", size.value);System.Gadget.Settings.write("flyout", flyout.value);}function fillInterfaceCombo(){debugLog("fillInterfaceCombo");try {for (var i = 0;i < interfaceCount; i++){Interface.options[Interface.length] = new Option(i + ": " + System.Gadget.document.parentWindow.NetLib.Description(i), i);}}catch(err) {debugLog("fillInterfaceCombo: "+err.name+" - "+err.message)}}function getURL(a){try{var xmlReq=new ActiveXObject("Microsoft.XMLHTTP");xmlReq.open("GET",a,false);xmlReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");xmlReq.send();if(xmlReq.status==200){return xmlReq.responseText}else{return false}}catch(urlData){return false}}function updateAvailable(){var urlData=getURL("http://www.addgadget.com/wireless_network_meter/version.htm");if(urlData===false){return false}var version="5.0";var a=parseFloat(version);var b=parseFloat(urlData);return b>a;}function showUpdate(){if(updateAvailable()){document.getElementById("newUpdate").style.display="block"}else{document.getElementById("noUpdate").style.display="block"}}